﻿using KsMusic.common;
using KsMusic.Model;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization.Json;

namespace KsMusic.API
{
    /// <summary>
    /// 酷我音乐API接口
    /// </summary>
    public class KuWoMusicAPI
    {
        // http://search.kuwo.cn/r.s?all=%E4%B8%80%E5%89%91%E8%BD%BB%E5%AE%89&ft=music&rformat=json&encoding=utf8
        public static MKuwo search(string key)
        {
            string url = string.Format("http://search.kuwo.cn/r.s?all={0}&ft=music&rformat=json&encoding=utf8", key);
            MyHttpClient client = new MyHttpClient(url);
            string json = client.ExecuteGet();

            MKuwo obj = new MKuwo();
            //DataContractJsonSerializer serializer = new DataContractJsonSerializer(obj.GetType());
            MKuwo list = JsonConvert.DeserializeObject<MKuwo>(json);

            return list;
        }
    }
}
